POV-Ray : Newsgroups : povray.general : Making faster #switch statements : Re: Making faster #switch statements Server Time
12 Aug 2024 17:13:59 EDT (-0400)
  Re: Making faster #switch statements  
From: Ron Parker
Date: 5 Mar 1999 14:42:11
Message: <36e03393.0@news.povray.org>
On Fri, 5 Mar 1999 19:28:28 +0100, Rudy Velthuis <rve### [at] gmxnet> wrote:
>
>Thorsten Froehlich schrieb in Nachricht <36dff57f.0@news.povray.org>...
>>In article <MPG.1149eb79f78933399896a1@news.povray.org> ,
>eag### [at] telekabelnl
>>(Phoenix) wrote:
>>
>>> In general, the time it takes to read in a jump table is far greater than
>>> just using the jump system that gets generated by an if-clause.
>>
>>That depends a lot on the density of the case conditions you have.
>
>Exactly. IMHO most compilers will do a faster switch() than numerous
>if-cascades. See also Ron Parker's output of two compilers. They're both
>faster than a simple cascade of if's would be.

Don't take my stuff as gospel, though.  I reverse-engineer stuff for a 
living, so what you see is from memory, probably not 100% accurate, 
could have even been hand-coded by some masochist, and is almost 
certainly filtered through my "understand-o-meter"

I don't know what about switch in POV would make it slow, other than the 
requirement that it parse even the parts it doesn't use, to find the parts 
it needs.  In this case, an array would be the best bet.  In other cases,
it's mostly empirical.  The idea should be to minimize the amount of
text in each case, but that won't always be the best solution either.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.